package com.apache.security.util;

import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponseWrapper;

/**
 *
 */
public class SecurityHttpServletResponse extends HttpServletResponseWrapper {

	public SecurityHttpServletResponse(HttpServletResponse response) {
		super(response);
	}

	public void setDateHeader(String name, long date) {
		super.setDateHeader(ResponseHeaderSecurityCheck.filterCLRF(name), date);
	}

	public void setIntHeader(String name, int value) {
		super.setIntHeader(ResponseHeaderSecurityCheck.filterCLRF(name), value);
	}

	public void addHeader(String name, String value) {
		super.addHeader(ResponseHeaderSecurityCheck.filterCLRF(name),
				XssUtil.xssFilter(ResponseHeaderSecurityCheck.filterCLRF(value), null));
	}

	public void setHeader(String name, String value) {
		super.setHeader(ResponseHeaderSecurityCheck.filterCLRF(name),
				XssUtil.xssFilter(ResponseHeaderSecurityCheck.filterCLRF(value), null));
	}

	//	public void sendRedirect(String location) throws IOException {
	//		if (!ResponseHeaderSecurityCheck.checkRedirectValid(location)) {
	//			throw new RuntimeException("redirect location " + location + " is not valid.");
	//		}
	//		super.sendRedirect(location);
	//	}

	public void setStatus(int sc, String sm) {
		super.setStatus(sc, XssUtil.xssFilter(sm, null));
	}

}
